package edu.uafs.museum;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

/**
 * This is the main activity class.
 */
public class MainActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        //Get the reference of the list view
        ListView myList = (ListView)findViewById(R.id.myList);
        
        //Make the list of items
        String[] values = {"Exhibitions", "Time", "Full Website", "View Intro Video"};
        
        //create an array adapter for the list view
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, values);
        
        //set the adapter to the listview
        myList.setAdapter(adapter);
        
        //make the action listener for the list view
        myList.setOnItemClickListener(new OnItemClickListener() {

			public void onItemClick(AdapterView<?> parent, View view, int position,
					long id) {
				// TODO Auto-generated method stub
				if (position == 0)
				{
					//if position is 0, means "Exhibitions", launch the exhibitions activity
					Intent intent = new Intent(getApplicationContext(), ExhibitsMain.class);
					startActivity(intent);
				}
				else if (position == 1)
				{
					//if position is 1, means "Time", launch the activity has the time content
					//call explicitly to the visit activity
					Intent intent = new Intent(getApplicationContext(), VisitActivity.class);
					//start the activity
					startActivity(intent);
				}
				else if (position == 2)
				{
					//if position is 2, launch the full website
					Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().getString(R.string.full_website)));
					startActivity(intent);
				}
				else if (position == 3)
				{
					//if position is 3, show the youtube video
					Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().getString(R.string.youtube_video)));
					startActivity(intent);
				}
			}
		});
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}
